home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 4 / Meeting Pearls Vol. IV (1996)(GTI - Schatztruhe)[!].iso / Pearls / midi / misc / Midi2TeX / src / tp_debug.c < prev    next >
C/C++ Source or Header  |  1994-03-24  |  6KB  |  261 lines

  1. /* Output from p2c, the Pascal-to-C translator */
  2. /* From input file "tp_debug.pas" */
  3.  
  4. #define TP_DEBUG_G
  5. #include "tp_debug.h"
  6.  
  7. #ifndef TP_DECL_H
  8. #include "tp_decl.h"
  9. #endif
  10. #ifndef TP_MISC_H
  11. #include "tp_misc.h"
  12. #endif
  13.  
  14. #include <stdlib.h>
  15.  
  16. /********************************************************/
  17. void WriteDebugInfo(Instring)
  18. Char *Instring;
  19. {
  20.   /********************************************************/
  21.   if (!Debug)
  22.     return;
  23.   switch (DebugOut) {
  24.  
  25.   case SCREEN:
  26. #ifdef __TURBOC__
  27.     cprintf("%s\r\n",Instring);
  28. #endif
  29. #ifndef __TURBOC__
  30.     printf("%s\r\n",Instring);
  31. #endif
  32.     break;
  33.  
  34.   case DEBFILE:
  35.     fprintf(DebugFile, "%s\n", Instring);
  36.     break;
  37.  
  38.   case PRINT:
  39. #ifdef __TURBOC__
  40.     cprintf("%s\r\n",Instring);
  41. #endif
  42. #ifndef __TURBOC__
  43.     printf("%s\r\n",Instring);
  44. #endif
  45.     break;
  46.   }
  47. }
  48.  
  49.  
  50. /********************************************/
  51. static void Help()
  52. {
  53.   /********************************************/
  54.   /* WriteLn('A correct call to Midi2TeX looks like this :'); */
  55.   printf("\n    MIDI2TEX midifilename [TeXfilename] [-option1] [-option2] ...\r\n\n");
  56.   printf("Switch -s suppresses note generation for tracks #\n");
  57.   printf("Switch -o determines order of tracks to display on staffs (up-down)\n\r");
  58.   printf("Switch -b assigns the bass clef to staff # (counted from top to bottom)\n\r");
  59.   printf("Switch -a1..-a5 assign the alto clefs to staff # (from top to bottom)\n\r");
  60.   printf("Switch -i assigns 2 or more staffs to one instrument\n\r");
  61.   printf("Switch -q determines the quantization note time, 1,2,4,8,16,32,64,128\n\r");
  62.   printf("Switch -p redefines the part time, (default a quarter note)\n\r");
  63.   printf("Switch -f forces the slopes of the beams to be zero\n\r");
  64.   printf("Switch -h changes the horizontal size of the score [1600  *0.1mm]\n\r");
  65.   printf("Switch -v changes the vertical size of the score [2400 *0.1mm]\n\r");
  66.   printf("Switch -m select music size [20,16]\n\r");
  67.   printf("Switch -e change \\elemskip value (in pt)\n\r");
  68. #ifdef ST
  69.   printf("Switch -x skips wait for key hit at end of program\n\r");
  70. #endif
  71.   printf("Switch -d@ switches on debugging info, @ can be any of the following :\n\r");
  72.   printf(" NONE    : no debugging,             SCREEN  : debug info to the screen\n\r");
  73.   printf(" PRINTER : debug info to the printer,   FILE : debug info to a file\n\r");
  74.   printf("Switch -? displays this help message\n\r");
  75. }
  76.  
  77.  
  78. /********************************/
  79. void ToBothEr(S)
  80. Char *S;
  81. {
  82.   /********************************/
  83.   Char STR1[256];
  84.  
  85.   sprintf(STR1, "Fatal error: %s", S);
  86.   WriteDebugInfo(STR1);
  87.   printf("\n\rFatal error:%s\n\r", S);
  88. }
  89.  
  90.  
  91. /********************************/
  92. void Warning(S)
  93. Char *S;
  94. {
  95.   /********************************/
  96.   Char STR1[256];
  97.  
  98.   sprintf(STR1, "Warning:%s", S);
  99.   WriteDebugInfo(STR1);
  100.   printf("Warning:%s\n\r", S);
  101. }
  102.  
  103.  
  104. /********************************************/
  105. void ErrorExit(errorcode)
  106. long errorcode;
  107. {
  108.   /********************************************/
  109.   Char STR1[256];
  110.   Char STR3[256];
  111.  
  112.   switch (errorcode) {
  113.  
  114.   case 0:
  115.     Help();
  116.     break;
  117.  
  118.   case 1:
  119.     ToBothEr(" No input file specified, or file does not exist ");
  120.     break;
  121.  
  122.   case 3:
  123.     sprintf(STR3, " MidiFile track %i is not ok", (int)CurTrack);
  124.     ToBothEr(STR3);
  125.     break;
  126.  
  127.   case 4:
  128.     ToBothEr(" Found a NoteOff without a NoteOn");
  129.     break;
  130.  
  131.   case 5:
  132.     ToBothEr(" Can only translate MIDI files of type 1, sorry...");
  133.     break;
  134.  
  135.   case 6:
  136.     ToBothEr(" Nil pointer detected in NoteOff search");
  137.     break;
  138.  
  139.   case 7:
  140.     ToBothEr(
  141.       " No. of order indices does not correspond with No. of tracks in file");
  142.     break;
  143.  
  144.   case 8:
  145.     ToBothEr(
  146.       " Staffindex out of range, you tried to change a staff attribute which I cannot handle");
  147.     break;
  148.  
  149.   case 9:
  150.     ToBothEr(" Heap exhausted during initializing memory");
  151.     break;
  152.  
  153.   case 10:
  154.     ToBothEr(
  155.       " The noteheap appeared to be empty during a note request to the noteheap");
  156.     break;
  157.  
  158.   case 11:
  159.     ToBothEr(" A note value exceeded 127, probably a program bug");
  160.     break;
  161.  
  162.   case 12:
  163.     ToBothEr(" Invalid PartTime entered, only one of 1,2,4,8,16,32 allowed");
  164.     break;
  165.  
  166.   case 13:
  167.     ToBothEr(" Invalid quantization time entered, use switch -? to get proper range");
  168.     break;
  169.  
  170.   case 14:
  171.     ToBothEr(" Can only define one multi-staff instrument in this version");
  172.     break;
  173.  
  174.   case 15:
  175.     ToBothEr(" Definition of an instrument of one track is useless");
  176.     break;
  177.  
  178.   case 16:
  179.     ToBothEr(" The Slurr-array is exhausted, too many slurrs (9) for MusicTeX");
  180.     break;
  181.  
  182.   case 17:
  183.     ToBothEr(" Process terminated by user ");
  184.     break;
  185.  
  186.   case 18:
  187.     ToBothEr(" The Beam-array is exhausted, too many beams (9) for MusicTeX");
  188.     break;
  189.  
  190.   case 19:
  191.     ToBothEr(" -h,-v,-m and -k option can only take one parameter");
  192.     break;
  193.  
  194.   case 20:
  195.     ToBothEr(" -m option parameter must be either 20 or 16");
  196.     break;
  197.  
  198.   case 21:
  199.     ToBothEr(" -k option parameter must be between -8 and 8");
  200.     break;
  201.  
  202.   case 22:
  203.     ToBothEr(" -a1..-a5 option parameter is not correct");
  204.     break;
  205.  
  206.   case 23:
  207.     ToBothEr(" -s option parameter is not correct");
  208.     break;
  209.  
  210.   case 24:
  211.     ToBothEr(" Unexpected end of MIDI file reached, file corrupted ?");
  212.     break;
  213.  
  214.   case 25:
  215.     ToBothEr(" Unable to open output file ");
  216.     break;
  217.  
  218.   case 89:
  219.     ToBothEr("tot en met i gekomen");
  220.     break;
  221.     
  222.   default:
  223.     ToBothEr(" Unknown error , either a corrupted midi file or a bug..");
  224.     break;
  225.   }
  226.   WriteDebugInfo("Program Terminated");
  227.   switch (errorcode) {
  228.  
  229.   case 1:
  230.   case 7:
  231.   case 8:
  232.   case 12:
  233.   case 13:
  234.   case 14:
  235.   case 15:
  236.     printf("Run program with switch -? to get additional help\n\r");
  237.     break;
  238.  
  239.   default:
  240.     if (MidiFileOpened) {
  241.       fprintf(TexFile,
  242.     "%%MIDI2TeX file processing aborted due to a non-run time error\n\r");
  243.       fprintf(TexFile, "\\finmorceau\n\r");
  244.       fprintf(TexFile, "\\bye\n\r");
  245.     }
  246.     break;
  247.   }
  248.   /* _Escape(0); */
  249.   exit(0);
  250. }  /* ErrorExit */
  251.  
  252.  
  253. void _TP_debug_init()
  254. {
  255.   static int _was_initialized = 0;
  256.   if (_was_initialized++)
  257.     return;
  258. }
  259. /* p2c: Note: Remember to call _TP_debug_init() in main program [215] */
  260. /* End. */
  261.